package com.itheima.service.Iml;

import com.itheima.mapper.CheckltemMapper;
import com.itheima.pojo.PageBean;
import com.itheima.pojo.R;
import com.itheima.pojo.Checkltem;
import com.itheima.service.CheckltemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CheckltemServiceIml implements CheckltemService {

    @Autowired
    private CheckltemMapper mapper;



    @Override
    public Map<String, Object>  findPage(PageBean pageBean) {
        Integer currentPage = pageBean.getCurrentPage();
        Integer pageSize = pageBean.getPageSize();
        String queryString = pageBean.getQueryString();
        Integer start = (currentPage-1)*pageSize;
        List<Map<String, Object>> list = mapper.selectList(start,pageSize,queryString);
        Integer total = mapper.getTotal();
        Map<String, Object> map = new HashMap<>();
        map.put("rows",list);
        map.put("total",total);
        return map;
    }

    @Override
    public boolean add(Checkltem checkltem) {
        mapper.insertCheckltem(checkltem);
        return true;
    }

    @Override
    public boolean delete(Integer id) {
        mapper.delete(id);
        return true;
    }

    @Override
    public Checkltem getById(Integer id) {

        return mapper.getById(id);
    }

    @Override
    public boolean update(Checkltem checkltem) {
        mapper.update(checkltem);
        return true;

    }
}
